package servlets;

import bean.Goods;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class CartServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession();
        Goods goods1 = new Goods("1", "小米手机", 1999.00, 1);
        Goods goods2 = new Goods("2", "苹果手机", 6999.00, 1);
        List<Goods> goodses = new ArrayList<Goods>();
        goodses.add(goods1);
        goodses.add(goods2);
        session.setAttribute("cart", goodses);
        response.getWriter().write(session.getAttribute("name") + ",您已经选购了两件商品<a/>");
        response.getWriter().write("<a href='/pay'>进入支付");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
